package com.googlecode.maurersmarbles.drawables;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.googlecode.maurersmarbles.Board;
import com.googlecode.maurersmarbles.Util;

public class SimpleBoardDrawable extends BoardDrawable {

	/**
	 * The color of an empty space.
	 */
	private static final int EMPTY_SPACE_COLOR = Color.DKGRAY;
	/**
	 * The paint used to draw the board background.
	 */
	private static Paint BACKGROUND_PAINT;
	/**
	 * The paint that is used to draw the discard rectangle.
	 */
	private static Paint DISCARD_PAINT;
	/**
	 * The paint used to draw a space.
	 */
	private static Paint SPACE_PAINT;

	/**
	 * Creates a new SimpleBoardDrawable.
	 * @param board the board to draw
	 * @param playerColors the array that contains the player colors
	 */
	public SimpleBoardDrawable(Board board, int[] playerColors) {
		super(board, playerColors);
	}

	@Override
	protected void drawBackground(Canvas canvas, int startX, int startY,
			int width, int height) {
		canvas.drawRect(startX, startY, startX + width, startY + height,
				BACKGROUND_PAINT);
	}

	@Override
	protected void drawDiscardRectangle(Canvas canvas, int startX, int startY,
			int width, int height) {
		Util.drawEmptyRectangle(canvas, startX, startY, width, height,
				DISCARD_PAINT);
	}

	@Override
	protected void drawEmptySpace(Canvas canvas, int startX, int startY,
			int width, int height) {
		SPACE_PAINT.setColor(EMPTY_SPACE_COLOR);
		canvas.drawCircle(startX + (int) (width / 2.0), startY
				+ (int) (height / 2.0), (float) (width / 2.0), SPACE_PAINT);
	}

	@Override
	protected void drawSafeSpace(Canvas canvas, int startX, int startY,
			int width, int height, int color) {
		SPACE_PAINT.setColor(color);
		canvas.drawCircle(startX + (int) (width / 2.0), startY
				+ (int) (height / 2.0), (float) (width / 2.0), SPACE_PAINT);
	}

	@Override
	protected void drawHomeSpace(Canvas canvas, int startX, int startY,
			int width, int height, int color) {
		drawSafeSpace(canvas, startX, startY, width, height, color);
	}

	@Override
	protected void drawStartSpace(Canvas canvas, int startX, int startY,
			int width, int height, int color) {
		drawSafeSpace(canvas, startX, startY, width, height, color);
	}

	static {

		BACKGROUND_PAINT = new Paint();
		BACKGROUND_PAINT.setColor(Color.LTGRAY);

		DISCARD_PAINT = new Paint();
		DISCARD_PAINT.setStrokeWidth(2);

		SPACE_PAINT = new Paint();

	}

}
